home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: uu4news.netcom.com!amc-gw!curtis
- From: curtis@amc.com (Curtis Green)
- Subject: Re: Memory Leak?
- Message-ID: <1996Mar14.165853.5180@amc.com>
- Organization: Applied Microsystems Corporation
- X-Newsreader: TIN [version 1.1 PL6]
- References: <4i2tr9$q6k@newsgate.dircon.co.uk>
- Date: Thu, 14 Mar 1996 16:58:53 GMT
-
- Chris Pyman (topher@dircon.co.uk) wrote:
- : Hi all
- :
- : Does anybody know whether the following would lead to a memory leak?
- : (Assume this is a Win32 Console App written with Visual C++ v2.0)
- :
- :
- : main(int argc, char* argv[]) {
- : CString s1("31-12-99");
- : CString s2;
- :
- : s2 = s1.Mid(0,2) + s1.Mid(3,2) + s1.Mid(6,2);
- :
- : cout << s2;
- : return 0;
- : }
-
- make sure that CString impelments a copy constructor, overloaded assignment
- operator (=), and proper destuctor. Make sure to read up on those in
- your book and you should be able to mimimize the problem. Food for thought:
- Look into useing the strstream class (derived from iostream). It allows
- you to tie a buffer to a stream and manipulate the buffer with all of the
- iostream functionality. I have not needed a string class since I cracked
- that nut.
-
- --
- Be seeing you...
-
- Curtis Green | Software Engineer
- curtis@amc.com | Applied Microsystems Embedded Systems
- | http://www.amc.com
- My opinions are |
- expressly mine | This year Khan escapes Earth on the Botany Bay.
- on my own. | (Cliff Clavin, 1996)
-